package com.app.tools;

import com.app.pojo.BackendUser;
import com.app.pojo.DevUser;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: App_SSM
 * @description: 拦截器
 * @author: Mr.peng
 * @create: 2020-06-10 16:21
 **/
public class Handert implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        DevUser devUser=(DevUser) request.getSession().getAttribute("devUserSession");
        BackendUser backendUser=(BackendUser)request.getSession().getAttribute("userSession");
        System.out.println("进入拦截器");
        if (devUser==null&&backendUser==null){
            response.sendRedirect(request.getContextPath()+"/index.jsp");
            return false;
        }
        return true;
    }

}
